<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateLeadsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('leads', function (Blueprint $table) {
            $table->engine='InnoDB';
            $table->increments('id')->comment('线索ID');
            $table->text('source')->comment('来源');
            $table->string('company_name',10)->comment('公司名称');
            $table->string('position',5)->comment('职位');
            $table->string('gender',5)->default('男')->comment('性别');
            $table->string('phone',16)->comment('联系方式');
            $table->text('email')->comment('电子邮箱');
            $table->text('address')->comment('地址');
            $table->time('contact_time')->comment('下次联系时间');
            $table->text('remark')->comment('备注');
            $table->unsignedInteger('user_id')->nullable()->default(0)->comment('客户负责人');
            $table->foreign('user_id')->references('id')->on('admin_users')->onUpdate('cascade')->onDelete('cascade');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('leads');
    }
}
